﻿using System.Collections.Generic;
using System.Xml.Linq;

namespace System.ServiceManager.Facade
{
    public class AndExpression : CriteriaElement
    {
        private readonly List<SimpleExpression> simpleExpressions;

        public AndExpression(XNamespace ns, List<SimpleExpression> simpleExpressions) : base(ns)
        {
            this.simpleExpressions = simpleExpressions;
        }

        internal override XElement ToXElement()
        {
            var addElement = new XElement(Namespace + "Expression",
                                          new XElement(Namespace + "And"));

            foreach (var simpleExpression in simpleExpressions)
            {
                addElement.Add(simpleExpression.ToXElement());
            }
            return addElement;
        }
    }
}